﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevDL.UserLimit.DALFactory;
using DevDL.UserLimit.IDAL;
using DevDL.UserLimit.Models;

namespace DevDL.UserLimit.BLL
{
    public class OperatorBLL
    {
        IDAL.IOperatorDAL iop = DALFactory.DataAccess.CreateOperatorDAL();
        /// <summary>
        /// 登录系统
        /// </summary>
        /// <param name="str1"></param>
        /// <param name="str2"></param>
        /// <param name="userInfo"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public bool CheckUser(string str1, string str2, ref Operator userInfo, ref string msg)
        {
            Operator userInfo1 = iop.GetUserInfoByUserId(str1);
            if (userInfo1 == null)
            {
                msg = "用户名错误";
                return false;
            }
            if (userInfo1.Password != str2)
            {
                msg = "密码错误";
                return false;
            }
            userInfo = userInfo1;
            return true;
        }
        public Operator GetUserInfoByUserId(string userId)
        {
            return iop.GetUserInfoByUserId(userId);
        }
        public List<Operator> GetOperators()
        {
            return iop.GetOperators();
        }
        public int Insert(Operator ope)
        {
            return iop.Insert(ope);
        }

        public int Delete(int id)
        {
            return iop.Delete(id);
        }

        public int Modify(Operator ope)
        {
            return iop.Modify(ope);
        }
        public List<Models.Operator> GetOperators(int id)
        {
            return iop.GetOperators(id);
        }
    }
}
